export default {
  install(Vue) {

    Object.defineProperties(Vue.prototype, {
      $breadcrumbs: {
        get() {
          return this.$route.matched;
        }
      }
    });

    Vue.component('breadcrumbs', {
      template: `
        <nav>
          <ul class="breadcrumbs" v-if="$breadcrumbs.length">
            <li v-if="crumb.meta.breadcrumb" v-for="(crumb, idx) in $breadcrumbs">
              <router-link v-if="idx !== $breadcrumbs.length - 1" :to="{ path: crumb.path }">{{ $t(crumb.meta.breadcrumb) }}</router-link>
              <span v-if="idx === $breadcrumbs.length - 1">{{ $t(crumb.meta.breadcrumb) }}</span>
            </li>
          </ul>
        </nav>`
    });
  }
};
